<template>
    <div>
      <el-button @click="talk">聊天（1$3）</el-button>
      <el-button @click="talk2">聊天(2$3)</el-button>
    </div>
</template>
<script>
import { findFriend, findMessageRecordByOne } from '@/api/consumer/consumer'
export default {
  name: 'Index',
  data() {
    return {
      // 聊天展示
      messageListPage: [],
      friendList: [],
      toUser: {},
      messageResult: {
        toUserId: 2,
        toUserRole: 3,
        images: 'https://cdn.pixabay.com/photo/2018/08/14/13/23/ocean-3605547_1280.jpg'
      }
    }
  },
  created() {
    this.findList()
  },
  methods: {
    findList() {
      findFriend().then(res => {
        this.friendList = res.data
      })
    },
    // 咨询
    talk() {
      this.messageResult.toUserRole = 3
      this.messageResult.toUserId = 1
      console.log(this.messageResult)
      findMessageRecordByOne(this.messageResult).then(res => {
        this.messageList = res.data
        console.log(this.messageList)
        this.$router.push({
          path: '/message/index',
          query: {
            messageRecordList: this.messageList,
            toUserId: this.messageResult.toUserId,
            toRoleId: this.messageResult.toUserRole,
            images: this.messageResult.images
          }
        })
      })
    },
    // 咨询
    talk2() {
      this.messageResult.toUserRole = 3
      this.messageResult.toUserId = 2
      console.log(this.messageResult)
      findMessageRecordByOne(this.messageResult).then(res => {
        this.messageList = res.data
        console.log(this.messageList)
        this.$router.push({
          path: '/message/index',
          query: {
            messageRecordList: this.messageList,
            toUserId: this.messageResult.toUserId,
            toRoleId: this.messageResult.toUserRole,
            images: this.messageResult.images
          }
        })
      })
    }
  }
}
</script>
<style scoped>
</style>
